import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-03-11
 * Time:22:02
 */
@WebServlet("/getParameter")
public class GetParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        //此处约定，请求中给定的query string 是形如：username=zhangsan&password=123
        //上述query string 就会被tomcat 自动解析成一个Map这样的结构
        //getparamenter就是在查询Map<String,String>里面的内容
        String username=req.getParameter("username");
        String password=req.getParameter("password");
        //就可以拿到这两内容后，做一些其他的任务处理
        System.out.println("username="+username);
        System.out.println("password="+password);
        resp.getWriter().write("ok");
    }
}
